<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生登陆注册</title>
</head>
<body>
	<jsp:useBean id="student" class="cn.edu.scau.chentingyu.bean.student">
		<jsp:setProperty name="student" property="*" />
	</jsp:useBean>
	<%
		try {
			Class.forName("com.mysql.jdbc.Driver"); // 加载数据库驱动，注册到驱动管理器
			String url = "jdbc:mysql://localhost:3306/jsp";// 数据库连接字符串
			String username = "root"; // 数据库用户名
			String databasepassword = "root"; // 数据库密码
			Connection conn = DriverManager.getConnection(url, username, databasepassword);
			String id = request.getParameter("id");
			String password = request.getParameter("password");
			String name = request.getParameter("name");
			String sex = request.getParameter("sex");
			String age = request.getParameter("age");
			
			PreparedStatement ps = conn.prepareStatement("update tb_student set id=?,password=?,name=?,sex=?,age=? where id=?");
			ps.setString(1, id);
			ps.setString(2, password);
			ps.setString(3, name);
			ps.setString(4, sex);
			ps.setString(5, age);
			ps.setString(6, id);
			int row = ps.executeUpdate();
			if (row > 0) {
				out.print("修改成功！");
			}
			ps.close();
			conn.close();
		} catch (Exception e) {
			out.print("修改失败");
			e.printStackTrace();
		}
	%>
	<br>
	<a href="login.jsp">返回</a>
</body>
</html>
